package HibernateOrderManagerment.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Table(name="order_item")
@Entity
public class OrderItem {
	@Id
	@Column(name="id")
	private long id ;
	@Column(name="amount")
	private int amount;
//	@Column(name="store_goods_id")
//	private long storeGoodsId;
//	@Column(name="orders_id")
//	private long ordersId;
	@ManyToOne
	@JoinColumn(name="store_goods_id")
	private StoreGoods storeGoods;
	@ManyToOne
	@JoinColumn(name="orders_id")
	private Orders orders;
	
	public OrderItem(){
		id=-1;
	}



	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}
	



	public StoreGoods getStoreGoos() {
		return storeGoods;
	}



	public void setStoreGoods(StoreGoods storeGoods) {
		this.storeGoods = storeGoods;
	}



	public Orders getOrders() {
		return orders;
	}



	public void setOrders(Orders orders) {
		this.orders = orders;
	}



	@Override
	public String toString() {
		return "OrderItem [id=" + id + ", amount=" + amount + ", storeGoodsId=" + storeGoods.getId() + ", ordersId=" + orders.getId() + "]";
	}



//	@Override
//	public String toString() {
//		return "OrderItem [id=" + id + ", amount=" + amount  + "]";
//	}
	
	
	
	

}
